package app.com.myanr;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

/**
 * Created by Administrator on 2017/9/12.
 */

public class RunnableActivity extends Activity {
    private final static String TAG = "My Runnable ===> ";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);

        new Thread(new MyRunnable()).start();  //开启线程

    /*
    * 可以简写成这样
    * */
        new Thread(new Runnable() {
            @Override
            public void run() {
                for(int i = 0; i<1000; i++)
                {
                    Log.e(TAG, Thread.currentThread().getName() + "i =  " + i);
                }
            }
        }).start();
    }


    public class MyRunnable implements Runnable{


        @Override
        public void run() {
            for(int i = 0; i<1000; i++)
            {
                Log.e(TAG, Thread.currentThread().getName() + "i =  " + i);
            }
        }
    }
}
